using System;
using System.Collections;
using System.Data;
using System.Web.UI.WebControls;
using Framework.Library;
using Framework.Library.Components.Commands;
using Framework.Library.Components.Security;
using Framework.Library.Utilities;

namespace Framework.Portal.Administrator.UserControls
{
    public partial class MainMenu : AuthenticatedControl
    {
        private int portalid = 0;

        protected void Page_Load(object sender, EventArgs e)
        {
            LoadMenu();
        }

        private void LoadMenu()
        {
            string strPortal = Request.QueryString["portalid"];
            if (!String.IsNullOrEmpty(strPortal))
                portalid = ConvertUtility.ToInt32(strPortal);
            else
                portalid = ConvertUtility.ToInt32(AppEnv.PortalId());
            DataTable dtCommands = null;

            if (!CurrentUser.IsSuperAdmin)
            {
                dtCommands = CommandController.GetCommandsForUserByPortalID(CurrentUser.UserID, portalid);
            }
            else
            {
                dtCommands = CommandController.GetCommands();
            }
            ucMainMenu.DataSource = dtCommands;
        }
    }
}